package com.ChenYaRou.www.controller.servlet;

import com.ChenYaRou.www.controller.EnrollServletController;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * 用户点击登录后查询登录信息是否正确
 * @ClassName Enroll
 * @Description TODO 登录成功后应该查询role角色 且把用户信息设置到cession 或cookie等上
 * @Author 86183
 * @Date 2022/4/29 23:36
 * @Version 1.0
 **/
public class EnrollServlet extends BaseServlet {

    private  EnrollServletController controller=new EnrollServletController();

    public void enroll(HttpServletRequest request,HttpServletResponse response){
        JSONObject json = JSON.parseObject(request.getParameter("json"));
        String userName = json.getString("userName");
        String password = json.getString("password");
        System.out.println(userName);
        System.out.println(password);
        try {
            response.getWriter().write(controller.enroll(userName,password));
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
